package com.redepronik.negosys.invfac.entity;

import java.io.Serializable;
import java.math.BigDecimal;
import java.sql.Timestamp;
import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import com.redepronik.negosys.rrhh.entity.Empleadocargo;
import com.redepronik.negosys.rrhh.entity.Proveedor;

/**
 * The persistent class for the ingreso database table.
 * 
 */
@Entity
@Table(schema = "invfac", name = "ingreso")
@NamedQuery(name = "Ingreso.findAll", query = "SELECT i FROM Ingreso i")
public class Ingreso implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	@SequenceGenerator(allocationSize = 1, name = "INGRESO_INGRESOID_GENERATOR", sequenceName = "INVFAC.INGRESO_INGRESOID_SEQ")
	@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "INGRESO_INGRESOID_GENERATOR")
	@Column(unique = true, nullable = false)
	private Long ingresoid;

	@Column(nullable = false)
	private Boolean activo;

	@Column(nullable = false, length = 25)
	private String codigodocumento;

	@Temporal(TemporalType.DATE)
	@Column(nullable = false)
	private Date fechafactura;

	@Column(nullable = false)
	private Timestamp fechaingreso;

	@Column(nullable = false)
	private Boolean pagado;

	// bi-directional many-to-one association to empleadoCargo
	@ManyToOne
	@JoinColumn(name = "bodegueroid")
	private Empleadocargo bodegueroid;

	// bi-directional many-to-one association to proveedor
	@ManyToOne
	@JoinColumn(name = "proveedorid", nullable = false)
	private Proveedor proveedor;

	@Column(nullable = false, precision = 20, scale = 10)
	private BigDecimal total;

	// bi-directional many-to-one association to Cuotaingreso
	@OneToMany(orphanRemoval = true, cascade = CascadeType.ALL, mappedBy = "ingreso")
	private List<Cuotaingreso> cuotaingresos;

	// bi-directional many-to-one association to Detalleingreso
	@OneToMany(orphanRemoval = true, cascade = CascadeType.ALL, mappedBy = "ingreso")
	private List<Detalleingreso> detalleingresos;

	// bi-directional many-to-one association to Tipodocumento
	@ManyToOne
	@JoinColumn(name = "tipodocumentoid", nullable = false)
	private Tipodocumento tipodocumento;

	public Ingreso() {
	}

	public Cuotaingreso addCuotaingreso(Cuotaingreso cuotaingreso) {
		getCuotaingresos().add(cuotaingreso);
		cuotaingreso.setIngreso(this);

		return cuotaingreso;
	}

	public Detalleingreso addDetalleingreso(Detalleingreso detalleingreso) {
		getDetalleingresos().add(detalleingreso);
		detalleingreso.setIngreso(this);

		return detalleingreso;
	}

	public Boolean getActivo() {
		return this.activo;
	}

	public Empleadocargo getBodegueroid() {
		return bodegueroid;
	}

	public String getCodigodocumento() {
		return this.codigodocumento;
	}

	public List<Cuotaingreso> getCuotaingresos() {
		return this.cuotaingresos;
	}

	public List<Detalleingreso> getDetalleingresos() {
		return this.detalleingresos;
	}

	public Date getFechafactura() {
		return this.fechafactura;
	}

	public Timestamp getFechaingreso() {
		return this.fechaingreso;
	}

	public Long getIngresoid() {
		return this.ingresoid;
	}

	public Boolean getPagado() {
		return this.pagado;
	}

	public Proveedor getProveedor() {
		return this.proveedor;
	}

	public Tipodocumento getTipodocumento() {
		return this.tipodocumento;
	}

	public BigDecimal getTotal() {
		return this.total;
	}

	public Cuotaingreso removeCuotaingreso(Cuotaingreso cuotaingreso) {
		getCuotaingresos().remove(cuotaingreso);
		cuotaingreso.setIngreso(null);

		return cuotaingreso;
	}

	public Detalleingreso removeDetalleingreso(Detalleingreso detalleingreso) {
		getDetalleingresos().remove(detalleingreso);
		detalleingreso.setIngreso(null);

		return detalleingreso;
	}

	public void setActivo(Boolean activo) {
		this.activo = activo;
	}

	public void setBodegueroid(Empleadocargo bodegueroid) {
		this.bodegueroid = bodegueroid;
	}

	public void setCodigodocumento(String codigodocumento) {
		this.codigodocumento = codigodocumento;
	}

	public void setCuotaingresos(List<Cuotaingreso> cuotaingresos) {
		this.cuotaingresos = cuotaingresos;
	}

	public void setDetalleingresos(List<Detalleingreso> detalleingresos) {
		this.detalleingresos = detalleingresos;
	}

	public void setFechafactura(Date fechafactura) {
		this.fechafactura = fechafactura;
	}

	public void setFechaingreso(Timestamp fechaingreso) {
		this.fechaingreso = fechaingreso;
	}

	public void setIngresoid(Long ingresoid) {
		this.ingresoid = ingresoid;
	}

	public void setPagado(Boolean pagado) {
		this.pagado = pagado;
	}

	public void setProveedor(Proveedor proveedor) {
		this.proveedor = proveedor;
	}

	public void setTipodocumento(Tipodocumento tipodocumento) {
		this.tipodocumento = tipodocumento;
	}

	public void setTotal(BigDecimal total) {
		this.total = total;
	}

}